<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="/favicon.ico">
    <link rel="Shortcut Icon" href="/favicon.ico" />
    <!--[if lt IE 9]>
        <script type="text/javascript" src="lib/html5shiv.js"></script>
        <script type="text/javascript" src="lib/respond.min.js"></script>
        <![endif]-->
    <link rel="stylesheet" type="text/css" href="../static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="../lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/style.css" />
    <link rel="stylesheet" href="./../lib/layui/css/layui.css">
    <!--[if IE 6]>
        <script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
        <script>DD_belatedPNG.fix('*');</script>
        <![endif]-->
    <title>新增用户</title>
</head>

<body>
    <div class="page-container">
        <form action="" method="post" class="form form-horizontal layui-form" id="form-article-add">
            <input type="" name="" id="visible_input" value="1" style="display:none;" />
            <input type="" name="" id="isDiscount_input" value="2" style="display:none;" />
            <input type="" name="" id="isHot_input" value="2" style="display:none;" />
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">用户名：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text"  value="" placeholder="" id="userName" name="">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">昵称：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text"  value="" placeholder="" id="nickName" name="">
                </div>
            </div>
            <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-2">真实姓名：</label>
                    <div class="formControls col-xs-8 col-sm-9">
                        <input type="text" class="input-text"  value="" placeholder="" id="realName" name="">
                    </div>
                </div>
                <div class="row cl">
                        <label class="form-label col-xs-4 col-sm-2">身份证号码：</label>
                        <div class="formControls col-xs-8 col-sm-9">
                            <input type="text" class="input-text"  value="" placeholder="" id="idCard" name="">
                        </div>
                    </div>
            <!-- <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">性别：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <div class="layui-form-item">
                        <input type="radio" name="sex" value="男" title="男" checked>
                        <input type="radio" name="sex" value="女" title="女">
                    </div>
                </div>
            </div> -->
                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-2">手机号：</label>
                    <div class="formControls col-xs-8 col-sm-9">
                        <input type="number" style="width:100%" class="input-text" value="" placeholder="" id="phone" name="">
                    </div>
                </div>
                <div class="row cl">
                        <label class="form-label col-xs-4 col-sm-2">登录密码：</label>
                        <div class="formControls col-xs-8 col-sm-9">
                            <input type="password" class="input-text" value="" placeholder="" id="pwd" name="">
                        </div>
                    </div>
                    <div class="row cl">
                            <label class="form-label col-xs-4 col-sm-2">确认密码：</label>
                            <div class="formControls col-xs-8 col-sm-9">
                                <input type="password" class="input-text"  value="" placeholder="" id="surePwd" name="">
                            </div>
                        </div>
                <div class="row cl">
                        <label class="form-label col-xs-4 col-sm-2">交易密码：</label>
                        <div class="formControls col-xs-8 col-sm-9">
                            <input type="password" class="input-text" value="" placeholder="" id="payPwd" name="">
                        </div>
                    </div>
                    <div class="row cl">
                            <label class="form-label col-xs-4 col-sm-2">确认交易密码：</label>
                            <div class="formControls col-xs-8 col-sm-9">
                                <input type="password" class="input-text"  value="" placeholder="" id="surePayPwd" name="">
                            </div>
                        </div>
                <div class="row cl">
                        <label class="form-label col-xs-4 col-sm-2">上级推荐用户手机号：</label>
                        <div class="formControls col-xs-8 col-sm-9">
                            <input type="number" style="width:100%" class="input-text" value="" placeholder="" id="upperPhone" name="">
                        </div>
                    </div>
                    <div class="row cl">
                            <label class="form-label col-xs-4 col-sm-2">推广等级：</label>
                            <div class="formControls col-xs-8 col-sm-9">
                                <input type="number" style="width:100%"  class="input-text" value="" placeholder="" id="extendLv" name="">
                            </div>
                        </div>
                        <div class="row cl">
                                <label class="form-label col-xs-4 col-sm-2">团队礼包等级：</label>
                                <div class="formControls col-xs-8 col-sm-9">
                                    <input type="number" style="width:100%"  class="input-text" value="" placeholder="" id="giftLv" name="">
                                </div>
                            </div>
                            <div class="row cl">
                                    <label class="form-label col-xs-4 col-sm-2">团队重销等级：</label>
                                    <div class="formControls col-xs-8 col-sm-9">
                                        <input type="number" style="width:100%"  class="input-text" value="" placeholder="" id="comLv" name="">
                                    </div>
                                </div>
                                <div class="row cl">
                                        <label class="form-label col-xs-4 col-sm-2">支付宝：</label>
                                        <div class="formControls col-xs-8 col-sm-9">
                                            <input type="text" class="input-text" value="" placeholder="" id="zfb" name="">
                                        </div>
                                    </div>
                                    <div class="row cl">
                                            <label class="form-label col-xs-4 col-sm-2">微信：</label>
                                            <div class="formControls col-xs-8 col-sm-9">
                                                <input type="text" class="input-text" value="" placeholder="" id="wx" name="">
                                            </div>
                                        </div>

                <div class="row cl">
			        <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
				    <button type="button" onClick="save_submit();" class="btn btn-primary radius">提交</button>
				    <button onClick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
			    </div>
		</div>
        </form>
    </div>
	<script src="./../static/jquery.min.js"></script>
	<script type="text/javascript" src="./../static/js/common.js"></script>
	<script type="text/javascript" src="../lib/layer/2.4/layer.js"></script>
    <script type="text/javascript" src="./../lib/layui/layui.js"></script>
    <script>
        layui.use('form', function () {
		    var form = layui.form;
        });
        function save_submit(){
            if($("#userName").val() == ''){
                layer.msg("请输入用户名")
            }else if($("#nickName").val() == ''){
                layer.msg("请输入昵称")
            }
            else if($("#realName").val() == ''){
                layer.msg("请输入真实姓名")
            }else if($("#idCard").val() == '' ||  !(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test($("#idCard").val()))){
                layer.msg("请输入有效的身份证号码")
                $("#idCard").val("")
            }
            else if($("#phone").val() == ''){
                layer.msg("请输入手机号")
            }else if(!(/^1(3|4|5|7|8)\d{9}$/.test($("#phone").val()))){
                layer.msg("手机号码有误，请重新输入")
                $("#phone").val("")
            }
            else if($("#pwd").val() == ''){
                layer.msg("请输入登录密码")
            }else if($("#pwd").val() != $("#surePwd").val()){
                layer.msg("登录密码不一致，请重新输入")
                $("#surePwd").val('')
            }else if($("#pwd").val() == $("#payPwd").val()){
                layer.msg("登录密码与交易密码不能一致，请重新输入")
            }
            else if($("#payPwd").val() == ''){
                layer.msg("请输入交易密码")
            }else if($("#payPwd").val() != $("#surePayPwd").val()){
                layer.msg("交易密码不一致，请重新输入")
                $("#surePayPwd").val('')
            }
            else if($("#upperPhone").val() == ''){
                layer.msg("请输入上级推荐用户手机号")
            }
            else if($("#extendLv").val() == ''){
                layer.msg("请输入推广等级")
            }else if($("#giftLv").val() == ''){
                layer.msg("请输入团队礼包等级")
            }else if($("#comLv").val() == ''){
                layer.msg("请输入团队商品等级")
            }else if($("#realName").val() == ''){
                layer.msg("请输入真实姓名")
            }else if($("#zfb").val() == ''){
                layer.msg("请输入支付宝")
            }else if($("#wx").val() == ''){
                layer.msg("请输入微信")
            }
            
            else{
                var userName = $("#userName").val(),
                    realName = $("#realName").val(),
                    phone = $("#phone").val(),
                    pwd = $("#pwd").val(),
                    payPwd = $("#payPwd").val(),
                    upperPhone = $("#upperPhone").val(),
                    extendLv = $("#extendLv").val(),
                    giftLv = $("#giftLv").val(),
                    comLv = $("#comLv").val(),
                    realName = $("#realName").val(),
                    zfb = $("#zfb").val(),
                    wx = $("#wx").val(),
                    idCard = $("#idCard").val(),
                    nickName = $("#nickName").val(),
                    floor = $("#floor").val();
                    console.log(userName)
                    $.ajax({
				        type: "post",
				        xhrFields: { withCredentials: true },
				        url: admin_url + '/kvmUser/registerUser',
				        data: { tokenUserId: userId, token: token,nickName:nickName,userName:userName,idCard:idCard,name:realName, mobile:phone,smobile:upperPhone,loginPwd:pwd,dealPwd:payPwd,lv:extendLv,teamGiftLv:giftLv,teamProductLv:comLv,wx:wx,alipay:zfb},
				        success: function (data) {
					        console.log(data)
                            if (data.code == 200) {
                            layer.msg('添加成功', {
                            time: 1000,
                            end: function () {
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                                window.parent.location.reload();
                            }
                        })
                    } else {
                        layer.msg(data.msg, {
                            time: 1500
                        })
                    }
				}
			})
            }
        }
        		// 取消功能
		function layer_close() {
			var index = parent.layer.getFrameIndex(window.name);
			parent.layer.close(index);
		}
    </script>
</body>

</html>